package main;

import java.util.Iterator;

import heterosetbis.*;

public class HeteroSetTestBis {
	public static void main(String[] args) {
		HeteroSet<Object> s1 = new HeteroHashSet<>();
		assert s1.size() == 0;
		assert s1.isEmpty();
		assert s1.add(1);
		assert !s1.add(1);
		assert s1.add("one");
		assert s1.add("two");
		assert s1.add(true);
		assert s1.add(false);
		assert s1.add(2.3);
		assert s1.size() == 6;
		assert !s1.isEmpty();
		String num = "Numbers:";
		Iterator<Number> nit = s1.iteratorSubtype(Number.class);
		while (nit.hasNext())
			num += " " + nit.next();
		System.out.println(num);
		num = "Numbers:";
		nit = s1.iterator(Number.class);
		while (nit.hasNext())
			num += " " + nit.next();
		System.out.println(num);
		for (Object el : s1)
			System.out.println(el);
		Iterator<String> sit = s1.iterator(String.class);
		String str = "";
		while (sit.hasNext())
			str += " " + sit.next();
		System.out.println(str);
		double d = 0.;
		Iterator<Double> dit = s1.iterator(Double.class);
		while (dit.hasNext())
			d += dit.next();
		System.out.println(d);
		boolean b = false;
		Iterator<Boolean> bit = s1.iterator(Boolean.class);
		while (bit.hasNext())
			b |= bit.next();
		System.out.println(b);
		assert s1.remove("two");
		assert !s1.remove("two");
		for (Object el : s1)
			System.out.println(el);
		HeteroSet<Number> s2 = new HeteroHashSet<>();
		assert s2.add(1);
		assert s2.add(2);
		assert s2.add(1.);
		assert s2.add(2.);
		assert s2.add(1L);
		assert s2.add(2L);
		assert !s2.add(1);
		assert s2.size() == 6;
		int i = 0;
		Iterator<Integer> iit = s2.iterator(Integer.class);
		while (iit.hasNext())
			i += iit.next();
		assert i == 3;
		long l = 0L;
		Iterator<Long> lit = s2.iterator(Long.class);
		while (lit.hasNext())
			l += lit.next();
		assert l == 3L;
		d = 0.;
		dit = s2.iterator(Double.class);
		while (dit.hasNext())
			d += dit.next();
		for (Object el : s2)
			System.out.println(el);
		
		System.out.println("TESTS PASSED!");
	}
}
